import request from './request'
//统一管理所有的api
//请求首页数据
//要拿结果里面的真正的data还得用上async、await，不能对请求返回的Promise直接解构赋值
// export const GetHomeData = async () => {
//   const {
//     data: res
//   } = await request.get('/index/index')
//   return res
// }
//也可以在响应拦截那里直接返回res.data
//获取首页数据
export const GetHomeData = () => request.get('/index/index')
//获取Popup搜索历史和热搜数据
export const GetPopupData = () => request.get('/search/index')
//获取搜索商品数据，需要传参，get请求可以进行解构参数 request.get('/goods/list',{params})
export const GetSearchData = (params) => request.get('/goods/list', params)
//获取搜索提示/实时搜索数据，需要传参，get请求可以进行解构参数 request.get('/goods/list',{params})
export const GetSearchTip = (keyword) => request.get('/search/helper', {
  'params': {
    keyword
  }
})
//删除历史记录请求
export const ClearSearchHistory = () => request.post('/search/clearhistory')

//搜索结果列表点击，获取商品详情
export const GetProductDetails = (params) => request.get('/goods/detail', params)
//获取相关商品数据
export const GetRelatedGoodsList = (params) => request.get('/goods/related', params)

//首页跳转页面
//Channel宫格页面分类数据请求,宫格频道
export const GetChannelData = (params) => request.get('/goods/category', params)
//分类页面商品列表请求
export const GetChannelGoodsList = (params) => request.get('/goods/list', params)
//品牌详情数据
export const GetBrandData = (params) => request.get('/brand/detail', params)
//品牌商品数据
export const GetBrandGoodsData = (params) => request.get('/goods/list', params)


//Topic专题数据请求
export const GetTopicGoodsList = (params) => request.get('/topic/list', params)
//Category分类数据请求
export const GetCateList = () => request.get('/catalog/index')
//当前分类数据请求
export const GetCurrentCateGoodsList = (params) => request.get('/catalog/current', params)


//登录请求
export const Login = (params) => request.post('/auth/loginByWeb', params)



//获取购物车产品数量
export const GetGoodsNum_Cart = () => request.get('/cart/goodscount')
//加入购物车
export const AddToCart = (params) => request.post('/cart/add', params)
//获取购物车数据
export const GetCartData = () => request.get('/cart/index')
//chekcbox按钮状态改变，更新购物车选中数据。
export const RefreshCartData_checkbox = (params) => request.post('/cart/checked', params)
//步进器状态改变，更新购物车选中数据。
export const RefreshCartData_stepper = (params) => request.post('/cart/update', params)
//删除商品
export const DeleteGood = (params) => request.post('/cart/delete', params)